package com.example.aesdemo

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.aesdemo.utils.AESEnCryptUtils
import com.example.aesdemo.utils.Constants
import java.nio.charset.StandardCharsets

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        initAes()
    }

    @Throws(Exception::class)
    private fun initAes() {
        val text = "Android"
        // 256位密钥 = 32 bytes Key
        AESEnCryptUtils.encrypt(text)
        val key = Constants.AES_KEY.toByteArray(StandardCharsets.UTF_8)
        //AESEnCryptUtils.decryptFromBase64(key,text)
    }
}